import sqlite3
conn = sqlite3.connect("F:/stocks.db",check_same_thread = False)
import pandas as pd

def gethistory(name = '平安银行', startdate = '2022-01-01', enddate = '2023-02-28', ):
    query = "SELECT * FROM basekline where 股票名称 = \'%s\'" %name \
            + 'and 日期 between \'%s\'' %  startdate + ' and \'%s\'' % enddate
    #print(query)
    result= pd.read_sql_query(query, con=conn)
    #print(result)
#     股票名称    股票代码       ts代码          日期  ...    振幅   涨跌幅   涨跌额   换手率
# 0    平安银行  000001     tscode  2022-01-04  ...  2.95  1.11  0.18  0.60
# 1    平安银行  000001     tscode  2022-01-05  ...  4.08  2.98  0.49  1.01
# 2    平安银行  000001     tscode  2022-01-06  ...  1.60 -0.18 -0.03  0.57
# 3    平安银行  000001     tscode  2022-01-07  ...  1.30  0.47  0.08  0.58
# 4    平安银行  000001     tscode  2022-01-10  ...  2.30 -0.06 -0.01  0.47
    return result

if __name__ == '__main__':
    print(gethistory())